<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/1/24
 * Time: 17:53
 */

namespace App\Http\Controllers\MiniProgramAdmin;

use App\Http\Logics\MiniProgramAdmin\CafeLogic;
use App\Http\Traits\CafeTrait;
use App\Http\Controllers\BaseController;
class CafeController extends BaseController
{
    use CafeTrait;


    /**
     * @SWG\Post(
     *     path="/cafe/updateWifi",
     *     tags={"Cafe"},
     *     description="更新咖啡馆wifi信息",
     *     operationId="updateCafeWifi",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string",
     *         @SWG\Items(type="string"),
     *         collectionFormat="csv"
     *     ),
     *     @SWG\Parameter(
     *         name="wifi_ssid",
     *         in="query",
     *         description="wifi_ssid",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="wifi_password",
     *         in="query",
     *         description="wifi密码",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="wifi_bssid",
     *         in="query",
     *         description="wifi_bssid",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function updateCafeWifi()
    {
        $loginSession = $this->loginSession;
        $wifi_ssid = $this->wifi_ssid;
        $wifi_bssid = $this->wifi_bssid;
        $wifi_password = $this->wifi_password;
        $data = [
            'loginSession' => $loginSession,
            'wifi_ssid' => $wifi_ssid,
            'wifi_bssid' => $wifi_bssid,
            'wifi_password' => $wifi_password
        ];
        $response = CafeLogic::updateCafeWifi($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/cafe/getWifi",
     *     tags={"Cafe"},
     *     description="获取咖啡馆wifi信息",
     *     operationId="getCafeWifi",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string",
     *         @SWG\Items(type="string"),
     *         collectionFormat="csv"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getCafeWifi()
    {
        $key = $this->key;
        $data = [
            'key' => $key
        ];
        $response = CafeLogic::getCafeWifi($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/cafe/list",
     *     tags={"Cafe"},
     *     description="获取咖啡馆列表",
     *     operationId="getCafeList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="name",
     *         in="query",
     *         description="咖啡馆名称",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="citycode",
     *         in="query",
     *         description="城市编码",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="mark_id_str",
     *         in="query",
     *         description="标签ID列表字符串",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="adcode",
     *         in="query",
     *         description="区域编码",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getCafeList()
    {
        $name = $this->name;
        $status = $this->status;
        $limit= $this->limit;
        $citycode = $this->citycode;
        $mark_id_str = $this->mark_id_str;
        $adcode = $this->adcode;
        $loginSession = $this->loginSession;
        $data = [
            'name' => $name,
            'status' => $status,
            'limit' => $limit,
            'citycode' => $citycode,
            'mark_id_str' => $mark_id_str,
            'adcode' => $adcode,
            'loginSession' => $loginSession
        ];
        $response = CafeLogic::getCafeList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/cafe/detail",
     *     tags={"Cafe"},
     *     description="获取某一个咖啡馆详情",
     *     operationId="getCafeDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="cafe_id",
     *         in="query",
     *         description="咖啡馆ID",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getCafeDetail()
    {
        $loginSession = $this->loginSession;
        $cafe_id = $this->cafe_id;
        $data = [
            'loginSession' => $loginSession,
            'cafe_id' => $cafe_id
        ];
        $response = CafeLogic::getCafeDetail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/cafe/update",
     *     tags={"Cafe"},
     *     description="更新咖啡馆详情信息",
     *     operationId="updateCafe",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="cafe_id",
     *         in="query",
     *         description="咖啡馆ID",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="latlng",
     *         in="query",
     *         description="咖啡馆经纬度",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="address",
     *         in="query",
     *         description="咖啡馆详细地址",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="logo",
     *         in="query",
     *         description="咖啡馆LOGO",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="since_year",
     *         in="query",
     *         description="咖啡馆创办时间",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="name",
     *         in="query",
     *         description="咖啡馆名称",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="open_time",
     *         in="query",
     *         description="咖啡馆开门时间",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="close_time",
     *         in="query",
     *         description="咖啡馆打样时间",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="outside_time",
     *         in="query",
     *         description="咖啡馆例外营业时间",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="day_off",
     *         in="query",
     *         description="咖啡馆店休时间",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="mobile",
     *         in="query",
     *         description="咖啡馆联系方式",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="summary",
     *         in="query",
     *         description="咖啡馆联简介",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="cover",
     *         in="query",
     *         description="咖啡馆封面",
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function updateCafe()
    {
        $loginSession = $this->loginSession;
        $cafe_id = $this->cafe_id;
        $latlng = $this->latlng;
        $address = $this->address;
        $logo = $this->logo;
        $since_year = $this->since_year;
        $name = $this->name;
        $open_time = $this->open_time;
        $close_time = $this->close_time;
        $outside_time = $this->outside_time;
        $day_off = $this->day_off;
        $mobile = $this->mobile;
        $summary = $this->summary;
        $cover = $this->cover;
        $data = [
            'cafe_id' => $cafe_id,
            'latlng' => $latlng,
            'address' => $address,
            'logo' => $logo,
            'since_year' => $since_year,
            'name' => $name,
            'open_time' => $open_time,
            'close_time' => $close_time,
            'outside_time' => $outside_time,
            'day_off' => $day_off,
            'mobile' => $mobile,
            'summary' => $summary,
            'cover' => $cover,
            'loginSession' => $loginSession
        ];
        $response = CafeLogic::updateCafe($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/cafe/photo",
     *     tags={"Cafe"},
     *     description="获取咖啡馆的所有图片",
     *     operationId="getCafePhoto",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="cafe_id",
     *         in="query",
     *         description="咖啡馆ID",
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getCafePhoto()
    {
        $cafe_id = $this->cafe_id;
        $data = [
            'cafe_id' => $cafe_id
        ];
        $response = CafeLogic::getCafePhoto($data);
    }
}